#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>



int main(int argc,char** argv){
/* 点分制IP 转换成网络字节序*/
	int ip_addr ;
	ip_addr = inet_addr("39.97.106.237");
	if(ip_addr == INADDR_NONE)
		printf("ERROR");
	printf("%x\n",ip_addr);
/* converts the Internet host address cp from the IPV4 number-and-dots
 * notation into binary form and stores it in the struct that inp points to*/
	int rc = -1;
	struct in_addr inet_ip_addr;
	rc = inet_aton("39.97.106.237",&inet_ip_addr);
	if(rc ==1)
		printf("%x\n",inet_ip_addr.s_addr);
	else
		printf("ERROR %d\n",rc);	
/* converts the Internet host address in ,given in network byte order , to a string in IPv4  dotted-decimal notation .the string is returned in statically allocated buffer ,which subsequent calls will overwrite*/
	char *str_ip;
	str_ip = inet_ntoa(inet_ip_addr);
	printf("IP:%s\n",str_ip);
	return 0;
}
